gccfandomcom_ja-20200214-history
Timevar print
概要 *gcc-4.1.0/gcc/timevar.cにて定義 *時間の表示 引数 *FILE *fp 実装 379 /* Summarize timing variables to FP. The timing variable TV_TOTAL has 380 a special meaning -- it's considered to be the total elapsed time, 381 for normalizing the others, and is displayed last. */ 382 383 void 384 timevar_print (FILE *fp) 385 { 386 /* Only print stuff if we have some sort of time information. */ 387 #if defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME) || defined (HAVE_WALL_TIME) 388 unsigned int /* timevar_id_t */ id; 389 struct timevar_time_def *total = &timevars[TV_TOTAL].elapsed; 390 struct timevar_time_def now; 391 392 if (!timevar_enable) 393 return; 394 395 /* Update timing information in case we're calling this from GDB. */ 396 397 if (fp 0) 398 fp = stderr; 399 400 /* What time is it? */ 401 get_time (&now); 402 403 /* If the stack isn't empty, attribute the current elapsed time to 404 the old topmost element. */ 405 if (stack) 406 timevar_accumulate (&stack->timevar->elapsed, &start_time, &now); 407 408 /* Reset the start time; from now on, time is attributed to 409 TIMEVAR. */ 410 start_time = now; 411 412 fputs (_("\nExecution times (seconds)\n"), fp); 413 for (id = 0; id < (unsigned int) TIMEVAR_LAST; ++id) 414 { 415 struct timevar_def *tv = &timevars[(timevar_id_t) id]; 416 const double tiny = 5e-3; 417 *timevar_id_tの最後か、使用していないtvであったらcontinue 418 /* Don't print the total execution time here; that goes at the 419 end. */ 420 if ((timevar_id_t) id TV_TOTAL) 421 continue; 422 423 /* Don't print timing variables that were never used. */ 424 if (!tv->used) 425 continue; 426 *余りにも微小な値の場合もcontinue 427 /* Don't print timing variables if we're going to get a row of 428 zeroes. */ 429 if (tv->elapsed.user < tiny 430 && tv->elapsed.sys < tiny 431 && tv->elapsed.wall < tiny 432 && tv->elapsed.ggc_mem < GGC_MEM_BOUND) 433 continue; 434 *表示 435 /* The timing variable name. */ 436 fprintf (fp, " %-22s:", tv->name); 437 438 #ifdef HAVE_USER_TIME 439 /* Print user-mode time for this process. */ 440 fprintf (fp, "%7.2f (%2.0f%%) usr", 441 tv->elapsed.user, 442 (total->user 0 ? 0 : tv->elapsed.user / total->user) * 100); 443 #endif /* HAVE_USER_TIME */ 444 445 #ifdef HAVE_SYS_TIME 446 /* Print system-mode time for this process. */ 447 fprintf (fp, "%7.2f (%2.0f%%) sys", 448 tv->elapsed.sys, 449 (total->sys 0 ? 0 : tv->elapsed.sys / total->sys) * 100); 450 #endif /* HAVE_SYS_TIME */ 451 452 #ifdef HAVE_WALL_TIME 453 /* Print wall clock time elapsed. */ 454 fprintf (fp, "%7.2f (%2.0f%%) wall", 455 tv->elapsed.wall, 456 (total->wall 0 ? 0 : tv->elapsed.wall / total->wall) * 100); 457 #endif /* HAVE_WALL_TIME */ 458 459 /* Print the amount of ggc memory allocated. */ 460 fprintf (fp, "%8u kB (%2.0f%%) ggc", 461 (unsigned) (tv->elapsed.ggc_mem >> 10), 462 (total->ggc_mem 0 463 ? 0 464 : (float) tv->elapsed.ggc_mem / total->ggc_mem) * 100); 465 466 putc ('\n', fp); 467 } 468 469 /* Print total time. */ 470 fputs (_(" TOTAL :"), fp); 471 #ifdef HAVE_USER_TIME 472 fprintf (fp, "%7.2f ", total->user); 473 #endif 474 #ifdef HAVE_SYS_TIME 475 fprintf (fp, "%7.2f ", total->sys); 476 #endif 477 #ifdef HAVE_WALL_TIME 478 fprintf (fp, "%7.2f ", total->wall); 479 #endif 480 fprintf (fp, "%8u kB\n", (unsigned) (total->ggc_mem >> 10)); 481 482 #ifdef ENABLE_CHECKING 483 fprintf (fp, "Extra diagnostic checks enabled; compiler may run slowly.\n"); 484 fprintf (fp, "Configure with --disable-checking to disable checks.\n"); 485 #endif 486 487 #endif /* defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME) 488 || defined (HAVE_WALL_TIME) */ 489 }